package zust.javaee.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import zust.javaee.entity.Tplayer;
import zust.javaee.service.PlayerService;

import java.util.List;
import java.util.logging.Logger;

@Controller
@RequestMapping("fm")
public class FreeMarkerController {


    @Autowired
    private PlayerService playerService;

//    private static Logger log = Logger.getLogger(loginCtrl.class);
    @RequestMapping(value = "/login")
    public ModelAndView login() {
        ModelAndView mav = new ModelAndView("/fm/index");
        mav.addObject("username", "笑傲江湖");
        mav.addObject("projectName", "Freemarker框架");

        List<Tplayer> tplayers = playerService.getAllPlayer();
        mav.addObject("players", tplayers);


        return mav;
    }
}
